const router = require('koa-router')();

router.get('/getRecentBlogs',async(ctx)=>{
    let res = await instance.blog.getRecent();
    try {
        ctx.body = {
            code : 200,
            data : res
        };
    }catch (error) {
        ctx.body = {
            code : 500,
            data : res
        }
    }
    
})

router.get('/getArticle/id',async(ctx)=>{
    let id = ctx.query.id;
    if(!id) {
        ctx.body = {
            code:500,
            data : {

            },
            message:'缺少文章ID'
        }
    }
    console.log('id = ',id);
    let res = await instance.blog.getArticleById(id);
    ctx.body = {
        code:200,
        data : res
    }
})


module.exports = router.routes();